import { lazy } from "react";
const modules = import.meta.glob("/src/components/**/*.jsx");

function lazyLoad(importer) {
  if (!importer) return undefined;
  return lazy(importer)
}

const components = {};

Object.keys(modules).forEach((path) => {
    const componentName = path
      .replace("/src/components/", "")
      .replace(/\.jsx$/, "");
    components[componentName] = lazyLoad(modules[path]);
  });

export default components;